﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZBJF.Warranty.Common.Common;
using ZBJF.Warranty.Model;
using ZBJF.Warranty.Model.ViewModel.SocketModel;

namespace ZBJF.Warranty.BLL
{
    public partial class WeiXinUserInfoService
    {
        #region 分页获取微信用户列表 + IQueryable<WeiXinUserInfo> GetPagingList(WeiXinUserListModel model, out int total)
        /// <summary>
        /// 分页获取微信用户列表
        /// </summary>
        /// <param name="model"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public IQueryable<WeiXinUserInfo> GetPagingList(WeiXinUserListModel model, out int total)
        {
            var whereExpression = PredicateExtensions.True<WeiXinUserInfo>();
            //真实姓名
            if (!string.IsNullOrWhiteSpace(model.RealName))
            {
                whereExpression = whereExpression.And(o => o.RealName.Contains(model.RealName));
            }
            //微信昵称
            if (!string.IsNullOrWhiteSpace(model.NickName))
            {
                whereExpression = whereExpression.And(o => o.NickName.Contains(model.NickName));
            }
            //报案单号
            //if (!string.IsNullOrWhiteSpace(model.WarrantyRecordNo))
            //{
            //    whereExpression = whereExpression.And(o => o.WeiXinUserInsuranceOrder.Where(s => s.InsuranceWarrantyRecord.WarrantyRecordNo == model.WarrantyRecordNo).Select(p => p.InsuranceWarrantyRecord.WarrantyRecordNo).Contains(model.WarrantyRecordNo));
            //}

            return LoadPagerEntities<WeiXinUserInfo>(model.PageIndex, model.iDisplayLength, out total,
                whereExpression, model.iSorts);
        } 
        #endregion
    }
}
